function guessNum() {
    let list = document.getElementById('list')
    let results = document.getElementById('results')
    //为啥显示？？？？
    results.style.display = 'block';
    let H = document.getElementById('height')
    let W= document.getElementById('weight')
    let BMI = document.getElementById('BMI')
    //为什么用number强制类型转换    函数不需要调用
    let status = document.getElementById('status')
    let BMI_val = null
    if (height.value==='' || weight.value==='') {
        alert('不能为空')
    } else {
        if (isNaN(height.value) || isNaN(weight.value)) {
            alert('请输入数字'),
            results.style.display = 'none',
            list.style.display='none'
        } else {
            BMI_val = Number(W.value) / ((Number(H.value) / 100) ** 2)
            let quota = document.querySelector('#quota')
            // let BMI_val =W.value/Math.pow(H.value/100,2)
            BMI_val= BMI_val.toFixed(1)
            console.log(BMI_val);
            BMI.innerText = BMI_val;
            quota.style.display = 'block';
            if ( BMI_val <= 18.4) {
                status.innerText = '偏瘦';
                quota.style.top = '62px';
            } else if (18.5 <= BMI_val && BMI_val <= 23.9) {
                status.innerText = '正常';
                quota.style.top = '93px';
            } else if (24 <= BMI_val && BMI_val <= 27.9) {
                status.innerText = '过重';
                quota.style.top = '124px';
            } else if (28 <= BMI_val ){
                status.innerText = '肥胖';
                quota.style.top = '157px';
            }
       }
    }
//历史记录
    let count = 0;
    if (count === 0) {
      list.innerHTML = ''
    }
    //渲染数据
    count += 1;
    let listDate=[]
    let now = new Date();
    let date = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`
    let itemDate = {
        date: date,
        h: height.value,
        w: weight.value,
        BMI: BMI_val
    }

    listDate.push(itemDate)
    list.innerHTML = ''
    listDate.forEach(function (item, index) {
        console.log(item);
         list.innerHTML +=`<tr>
                        <td>${index+1}</td>
                        <td>${item.date}</td>
                        <td>${item.h}</td>
                        <td>${item.w}</td>
                        <td>${item.BMI}</td>
                        <td> <a href="javascript:;">删除</a></td>
                    </tr>`
    })
   /*  删除操作？
    let as = document.querySelectorAll('a');
    for (let i = 0; i < as.length; i++){
        as[i].onclick = function () {
            tbody.removeChild(this.parentNode)
        }
    } */
   
//quota
}
//表格各行换色
let tab = document.querySelector('table').querySelectorAll('tr');
    for (let i = 0; i < tab.length; i++){
        tab[i].onmouseover = function () {
            this.className = 'bg';
        }
        tab[i].onmouseout = function () {
            this.className = '';
        }
}
//表格各行换色
//显示隐藏文本框内容
   height.onfocus = function () {
       if (this.value === '身高') {
           this.value = '';
       }
       this.style.color='#333'
    }
    height.onblur = function () {
        if (this.value === '') {
        this.value='身高'
        }
         this.style.color='#999'
    }
    weight.onfocus = function () {
    if (this.value === '体重') {
           this.value = '';
        }
         this.style.color='#333'
    }
    weight.onblur = function () {
   if (this.value === '') {
        this.value='体重'
        }
         this.style.color='#999'
    }
    //显示隐藏文本框内容 



